<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>用户详情</title>
</head>
<link href="../common/layui/css/layui.css" rel="stylesheet">
<link href="css/commonStyle.css" rel="stylesheet">
<body>
<div id="user-detail" class="layui-col-md12" style="padding: 20px;">
    <div class="layui-row">
        <div class="layui-col-xs4">
            <img id="avatar" src="" style="width: 300px;" onerror="this.src='/pages/img/ic_avatar.png'" class='roundAvatar checked_avatar' style="border-radius: 10px;">
        </div>
        <div class="layui-col-xs4 layui-form-pane">
            <div class="layui-form-item">
                <label class="layui-form-label">昵称</label>
                <div class="layui-input-block">
                    <input type="text" id="nickname" disabled autocomplete="off" placeholder="正在加载..." class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">身份证</label>
                <div class="layui-input-block">
                    <input type="text" id="idcard" disabled autocomplete="off" placeholder="正在加载..." class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">姓名</label>
                <div class="layui-input-block">
                    <input type="text" id="name" disabled autocomplete="off" placeholder="正在加载..." class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">支付宝总充</label>
                <div class="layui-input-block">
                    <input type="text" id="alipayRechargeNum" disabled autocomplete="off" placeholder="正在加载..." class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">银行卡总充</label>
                <div class="layui-input-block">
                    <input type="text" id="bankCardRechargeNum" disabled autocomplete="off" placeholder="正在加载..." class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">提现总额</label>
                <div class="layui-input-block">
                    <input type="text" id="withdrawNum" disabled autocomplete="off" placeholder="正在加载..." class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">余额</label>
                <div class="layui-input-block">
                    <input type="text" id="balance" disabled autocomplete="off" placeholder="正在加载..." class="layui-input">
                </div>
            </div>
        </div>

        <div class="layui-col-xs4 layui-form-pane">
            <div class="layui-form-item">
                <label class="layui-form-label">用户ID</label>
                <div class="layui-input-block">
                    <input type="text" id="userId" disabled autocomplete="off" placeholder="正在加载..." class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">手机号</label>
                <div class="layui-input-block">
                    <input type="text" id="phone" disabled autocomplete="off" placeholder="正在加载..." class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">实人认证</label>
                <div class="layui-input-block">
                    <input type="text" id="realPerson" disabled autocomplete="off" placeholder="正在加载..." class="layui-input">
                </div>
            </div>
        </div>
    </div>
    <div class="layui-row">
        <!-- 好友管理 -->
        <div id="myFriends" class="layui-card">
            <!--<div class="layui-card-header user_table_open table_topTitle_space">
                <button id="friendsInfo_y" class="layui-btn motif_button_style friendsInfo" onclick="User.exportExcelFriends()">
                    导出好友明细
                </button>
            </div>-->
            <!--多选删除-->
            <!--<div class="mustDelete">
                <img src="images/draw/question.png" class="small_icon">
                <span class="chooseDeleteCount"></span>
                <span class="checkDeleteUsersFriends checkDelete" onclick="User.checkDeleteUsersFriends()" lay-event="delete">删除
            </span>
            </div>-->
            <div class="layui-card-header layui_card_header_title layui_card_header_spare">好友列表</div>
            <div class="layui-card-body" style="margin-top: 20px;">
                <table id="myFriends_table" lay-filter="myFriends_table"></table>
                <!--<div class="characters_center padding_upDown_space">
                    <button onclick="User.button_back()" class="layui-btn layui-btn-primary default_button_style">
                        返回
                    </button>
                </div>-->
            </div>
        </div>
    </div>
    <div class="layui-row">
        <div id="room_table_div" class="layui-card module_interval">
            <div class="layui-card-header layui_card_header_title layui_card_header_spare">
                群组列表
            </div>
            <div class="layui-card-body" style="margin-top: 20px;">
                <table id="room_table" lay-filter="room_table"></table>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" src="../common/jquery/jquery.min.js"></script>
<script type="text/javascript" src="assets/xss-filters.1.2.7.min.js"></script>
<script type="text/javascript" src="../common/layui/layui.all.js"></script>
<script type="text/javascript" src="../assets/js/jquery.md5.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/authorityManagement.js"></script>
<script type="text/javascript" src="js/console_ui.js"></script>

<script>
    init();
    function init(){
        let userId = getUrlParam("userId");
        Common.invoke({
            url:request('/console/getUpdateUser'),
            data:{
                userId:userId
            },
            success:function(result){
                if(result.data!=null){
                    $("#avatar").attr("src", Common.getAvatarUrl(userId));
                    $("#userId").val(result.data.userId);
                    $("#idcard").val(Common.isNil(result.data.idcard)?"暂无数据":result.data.idcard);
                    $("#nickname").val(Common.filterHtmlData(result.data.nickname));
                    $("#phone").val(Common.filterHtmlData(result.data.phone));
                    $("#name").val(Common.isNil(result.data.name)?"暂无数据":Common.filterHtmlData(result.data.name));
                    $("#balance").val(result.data.balance);
                    $("#alipayRechargeNum").val(result.data.alipayCount);
                    $("#bankCardRechargeNum").val(result.data.bankcardCount);
                    $("#withdrawNum").val(result.data.withdrawCount);
                    $("#realPerson").val(result.data.realNameCertified === 0? '未认证' : '认证成功');
                }
            }
        });
        var tableInsFriends = layui.table.render({
            elem: '#myFriends_table'
            // ,toolbar: '#toolbarUsersFriends'
            ,url:request("/console/friendsList")+"&userId="+userId
            ,id: 'myFriends_table'
            ,page: {
                layout: [ 'prev', 'page', 'next','limit', 'count', 'skip'] //自定义分页布局
                ,groups: 3 //只显示 1 个连续页码
                ,first: false //不显示首页
                ,last: false //不显示尾页
            }
            ,curr: 0
            ,limit:Common.limit
            ,limits:Common.limits
            ,groups: 7
            ,cols: [[ //表头
                // {type:'checkbox',fixed:'left'}// 多选
                /*,*/{field: 'toUserId', title: '好友Id', width:120,sort: true}
                ,{field: 'toNickname', title: '好友昵称', width:150,sort: true}
                ,{field: 'status', title: '状态',sort: true, width:120,templet : function (d) {
                        if(d.status == -1)
                            return "黑名单";
                        else if(d.status == 1)
                            return "关注"
                        else if(d.status == 2)
                            return "好友";
                    }}
                ,{field: 'blacklist', title: '是否拉黑', width:120,sort: true,templet : function (d) {
                        if(d.blacklist == 1)
                            return "是";
                        else
                            return "否";
                    }}
                ,{field: 'isBeenBlack', title: '是否被拉黑', width:120,sort: true,templet : function (d) {
                        if(d.isBeenBlack == 1)
                            return "是";
                        else
                            return "否";
                    }}
                ,{field: 'offlineNoPushMsg', title: '是否消息免打扰',width: 150,sort: true,templet : function (d) {
                        if(d.offlineNoPushMsg == 1)
                            return "是";
                        else
                            return "否";
                    }}
                ,{field: 'createTime', title: '成为好友的时间',width: 170,sort: true,templet: function(d){
                        return UI.getLocalTime(d.createTime);}}
                // ,{fixed: 'right', width: 600,title:"操作", align:'left', toolbar: '#delFriends'}
            ]]
            ,done:function(res, curr, count){
                checkRequst(res);
                // $(".user_table").hide();
                // $("#myFriends").show();
                // $(".userListSearch").hide();
                // $(".visitPathDiv").hide();
                /*if(localStorage.getItem("role")!=6){
                    $(".friendsInfo").hide();
                }*/
                var pageIndex = tableInsFriends.config.page.curr;//获取当前页码
                var resCount = res.count;// 获取table总条数
                currentCount = resCount;
                currentPageIndex = pageIndex;
            }
        });
        var tableInRoom = layui.table.render({
            elem: '#room_table'
            ,url:request("/console/room/list/his")+"&userId="+userId
            // ,toolbar: '#toolbarDemo'
            ,id: 'room_table'
            ,page: {
                layout: [ 'prev', 'page', 'next','limit', 'count', 'skip'] //自定义分页布局
                ,groups: 3 //只显示 1 个连续页码
                ,first: false //不显示首页
                ,last: false //不显示尾页
            }
            ,curr: 0
            ,limit:Common.limit
            ,limits:Common.limits
            ,groups: 7
            ,cols: [[ //表头
                // {type:'checkbox'}
                ,{field: 'name', title: '群组名称',width:'13%'}
                ,{field: 'desc', title: '群组说明',width:'13%'}
                ,{field: 'userId', title: '创建者Id', sort: true, width:'12%'}
                ,{field: 'nickname', title: '创建者昵称', width:'12%'}
                ,{field: 'userSize', title: '群人数',sort: true, width:'12%'}
                ,{field: 's', title: '状态',sort: true, width:'12%',templet:function (d) {
                        if(1 == d.s){
                            return "正常";
                        }else {
                            return "被封锁";
                        }
                    }}
                ,{field: 'isSecretGroup', title: '是否为私密群组',sort: true, width:'12%',templet:function (d) {
                        if(1 == d.isSecretGroup){
                            return "私密群组";
                        }else {
                            return "普通群组";
                        }
                    }}
                ,{field: 'createTime',title:'创建时间',width:'15%',sort: true,templet: function(d){
                        return UI.getLocalTime(d.createTime);
                    }}
                // ,{fixed: 'right',title:"操作", width:'24%' , align:'center', toolbar: '#roomListBar'}
            ]]
            ,done:function(res, curr, count){
                checkRequst(res);
                //开启下拉菜单
                // dropdown.suite();
                //权限判断
                /*var arr=['room-delete','room-chatRecord','room-randUser','room-member','room-sendMsg','room-msgCount','room-modifyConf','room-locking','room-add'];
                manage.authButton(arr);
                //获取当前每页大小
                var recodeLimit =  $(".layui-laypage-limits").find("option:selected").val();
                if (undefined != recodeLimit){
                    //获取零时保留的值
                    var last_value = $("#roomList_limlt").val();
                    //设置零时保留的值
                    $("#roomList_limlt").val(recodeLimit);
                    //判断是否改变了每页大小数
                    if (last_value != recodeLimit){
                        // 刷新
                        layui.table.reload("room_table",{
                            url:request("/console/roomList"),
                            page: {
                                curr: 1 //重新从第 1 页开始
                            }
                        })
                    }
                }*/

                var pageIndex = tableInRoom.config.page.curr;//获取当前页码
                var resCount = res.count;// 获取table总条数
                currentCount = resCount;
                currentPageIndex = pageIndex;

                //操作按钮田间css
                $("#operation").addClass('operationClass');

                $(".group_name").val("");
                $(".leastNumbers").val("");
                $(".keyWord").addClass("keyWord");

                if(count==0&&lock==1){
                    layer.msg("暂无数据",{"icon":2});
                    renderTable();
                }
                lock=0;


                /*Room.operation('-1');
                if (operationFlag){
                    Room.openOperation();
                    $("#operation").html('关闭操作');
                }else{
                    Room.closeOperation();
                    $("#operation").html('打开操作');
                }*/

                //禁止全选按钮操作
                /*$('th[data-field="0"] .layui-table-cell').html('');

                //设置默认勾选
                for(var i=0;i<res.data.length;i++){
                    if (checker_ids.includes(res.data[i].id)){
                        res.data[i]["LAY_CHECKED"]='true';
                        var index= res.data[i]['LAY_TABLE_INDEX'];
                        $('.layui-table tr[data-index=' + index + '] input[type="checkbox"]').prop('checked', true);
                        $('.layui-table tr[data-index=' + index + '] input[type="checkbox"]').next().addClass('layui-form-checked');
                    };
                }*/
            }
        });
    }
    function getUrlParam(name) {
        var zhengze= new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //正则匹配  (^|&) 开头    (&|$)以&结尾
        var para = window.location.search.substr(1).match(zhengze);
        if (para != null) {
            return decodeURIComponent(para [2]);  // 也可以 这样写 unescape(para [2]);
        }
        return '';
    }
</script>
</body>
</html>